package top.suven.base.core.mybatis.crud;

import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CommonCrudMapper<E> {

    @InsertProvider(type = CommonCrudProvider.class, method = "createEntity")
    Integer createEntity(@Param("entity") E entity);

    @InsertProvider(type = CommonCrudProvider.class, method = "batchCreateEntity")
    Integer batchCreateEntity(@Param("entityList") List<E> entity);

    @SelectProvider(type = CommonCrudProvider.class, method = "findPageEntity")
    List<E> findPageEntity(@Param("entity") E entity, @Param("start") int start, @Param("pageSize") int pageSize);

    @SelectProvider(type = CommonCrudProvider.class, method = "retrieveEntity")
    E retrieveEntity(@Param("entity") E entity);

    @SelectProvider(type = CommonCrudProvider.class, method = "findEntity")
    List<E> findEntity(@Param("entity") E entity);

    @SelectProvider(type = CommonCrudProvider.class, method = "findEntityByCondition")
    List<E> findEntityByCondition(@Param("entity") E entity, @Param("condition") String condition);

    @SelectProvider(type = CommonCrudProvider.class, method = "findEntityIncludeDeleted")
    List<E> findEntityIncludeDeleted(@Param("entity") E entity);

    @SelectProvider(type = CommonCrudProvider.class, method = "countEntity")
    Integer countEntity(@Param("entity") E entity);

    @SelectProvider(type = CommonCrudProvider.class, method = "countEntityByCondition")
    Integer countEntityByCondition(@Param("entity") E entity, @Param("condition") String condition);

    @SelectProvider(type = CommonCrudProvider.class, method = "findEntityIncludeDeletedByCondition")
    List<E> findEntityIncludeDeletedByCondition(@Param("entity") E entity, @Param("condition") String condition);

    @UpdateProvider(type = CommonCrudProvider.class, method = "updateEntity")
    Integer updateEntity(@Param("entity") E entity);

    @DeleteProvider(type = CommonCrudProvider.class, method = "deleteEntity")
    Integer deleteEntity(@Param("entity") E entity);

    @DeleteProvider(type = CommonCrudProvider.class, method = "deleteEntityByCondition")
    Integer deleteEntityByCondition(@Param("entity") E entity, @Param("condition") String condition);

}
